package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CardRightdetail;
import com.ktgj.customer.service.ICardRightdetailService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 卡权益Controller
 * 
 * @author ruoyi
 * @date 2021-07-30
 */
@RestController
@RequestMapping("/cardRightdetail")
public class CardRightdetailController extends BaseController
{
    @Autowired
    private ICardRightdetailService cardRightdetailService;

    /**
     * 查询卡权益列表
     */
    @PreAuthorize(hasPermi = "customer:cardRightdetail:list")
    @GetMapping("/list")
    public TableDataInfo list(CardRightdetail cardRightdetail)
    {
        startPage();
        List<CardRightdetail> list = cardRightdetailService.selectCardRightdetailList(cardRightdetail);
        return getDataTable(list);
    }

    /**
     * 导出卡权益列表
     */
    @PreAuthorize(hasPermi = "customer:cardRightdetail:export")
    @Log(title = "卡权益", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CardRightdetail cardRightdetail) throws IOException
    {
        List<CardRightdetail> list = cardRightdetailService.selectCardRightdetailList(cardRightdetail);
        ExcelUtil<CardRightdetail> util = new ExcelUtil<CardRightdetail>(CardRightdetail.class);
        util.exportExcel(response, list, "卡权益数据");
    }

    /**
     * 获取卡权益详细信息
     */
    @PreAuthorize(hasPermi = "customer:cardRightdetail:query")
    @GetMapping(value = "/{cardRightdetailId}")
    public AjaxResult getInfo(@PathVariable("cardRightdetailId") Long cardRightdetailId)
    {
        return AjaxResult.success(cardRightdetailService.selectCardRightdetailById(cardRightdetailId));
    }

    /**
     * 新增卡权益
     */
    @PreAuthorize(hasPermi = "customer:cardRightdetail:add")
    @Log(title = "卡权益", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CardRightdetail cardRightdetail)
    {
        return toAjax(cardRightdetailService.insertCardRightdetail(cardRightdetail));
    }

    /**
     * 修改卡权益
     */
    @PreAuthorize(hasPermi = "customer:cardRightdetail:edit")
    @Log(title = "卡权益", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CardRightdetail cardRightdetail)
    {
        return toAjax(cardRightdetailService.updateCardRightdetail(cardRightdetail));
    }

    /**
     * 删除卡权益
     */
    @PreAuthorize(hasPermi = "customer:cardRightdetail:remove")
    @Log(title = "卡权益", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cardRightdetailIds}")
    public AjaxResult remove(@PathVariable Long[] cardRightdetailIds)
    {
        return toAjax(cardRightdetailService.deleteCardRightdetailByIds(cardRightdetailIds));
    }
}
